// See https://github.com/Jias/natty-fetch for more details.
//可以创建一个上下文对象，创建这个对象的参数就是上下文配置
//1.定义全局配置2.定义接口模块 1.上下文配置，2.接口api配置  此处未设置全局
//data:固定参数，fit数据结构预处理,mock模式开启时的请求地址前缀
require('./handleData');
const context = salt.fetch.context({
    mockUrlPrefix: '/mock/',
    urlPrefix: '/',
    mock: true,
    // jsonp: true,
    withCredentials: false,
    traditional: true,
    data: {
        _tb_token_: ''
    },
    timeout: 5000,
    fit: function(response) {
        let data = JSON.parse(response);
        let ret = {success:!data.errcode}; 
        if(ret.success){
            ret.content =  {list:window.dealData.dealTime(data.recordresult)};
            // console.log("content="+JSON.stringify(ret.content));
        }else{
            ret.error = {message:data.errmsg};
        }
        return ret;
    }
});
//2.定义接口模块 mockUrl:mock模式开启时的请求地址 url请求地址
//SomeModuleAPI 类 getSomeInfo 方法名
context.create('SomeModuleAPI', {
    getSomeInfo: {
        mockUrl: 'query/getSomeInfo.json',
        url: 'query/getSomeInfo.json'
      },
   getOfficeTime:{
       mockUrl:'query/getOfficeTime.json'
   }
});
//钉钉客户端配置
context.create("dingClientAPI",{
     getConfigInfo: {
        mockUrl: 'query/getConfigInfo.json',
      },
   getUserInfo:{
       mockUrl:'query/getUserInfo.json'
   }
});
module.exports = context.api;
